package com.xzr.hospitalregister.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xzr.hospitalregister.R;

import java.util.List;

/**
 * Created by Administrator on 2018/1/27 0027.
 */

public class AAAA extends RecyclerView.Adapter<AAAA.MyHolder> {
    private List<String> data;
    private Context context;

    public AAAA(List<String> data, Context context) {
        this.data = data;
        this.context = context;
    }

    private OnClickListener onClickListener;

    public void setOnClickListener(OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }

    public interface OnClickListener {
        void onLongClickListener(int position);
    }

    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyHolder(LayoutInflater.from(context).inflate(R.layout.aaaa, null));
    }

    @Override
    public void onBindViewHolder(MyHolder holder, final int position) {
        holder.edittext_patient1.setText(data.get(position));


        holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                onClickListener.onLongClickListener(position);
                return true;
            }
        });
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    class MyHolder extends RecyclerView.ViewHolder {
        TextView edittext_patient1;

        public MyHolder(View itemView) {
            super(itemView);
            edittext_patient1 = (TextView) itemView.findViewById(R.id.edittext_bingRen);
        }
    }
}
